<?php defined('SYSPATH') OR die('No direct access allowed.');

class User_Model extends Auth_User_Model {
	protected $has_one = array('twitter_access');
	protected $has_many = array('posts', 'triggers');
	protected $has_and_belongs_to_many = array('preferences', 'roles');

	public function create($data)
	{
		$user = ORM::factory('user');
		foreach ($data as $field => $value)
		{
			$user->$field = $value;
		}
    $user->add(ORM::factory('role', 'login'));

    $id = $user->save();
    if ($user->saved) {
    	return $id;
    }
    else {
    	return false;
    }
	}

}
